import BaseManager from "../base/BaseManager";
import BaseAsset from "../base/BaseAsset";
import CCCAsset from "./CCCAsset";

enum Engine {
    /** cocos creator */
    CCC,
    /** laya */
    Laya
}

/**
 * 资源加载管理
 * @author cls
 * @date 2020-01-20
 */
export default class AssetsManager extends BaseManager {
    /** 引擎 */
    private _engine: Engine = Engine.CCC;

    /** 资源加载库 */
    private _assetLoader: BaseAsset = null;

    constructor(){
        super();
        let loader: BaseAsset = null;
        switch(this._engine){
            case Engine.CCC: {
                loader = new CCCAsset();
                break;
            }
        }
        this._assetLoader = loader;
    }

    /** 加载预制体 */
    async loadPrefab(path: string): Promise<any> {
        return this._assetLoader.loadPrefab(path);
    }

    /** 加载帧图片 */
    async loadImage(path: string): Promise<any> {
        return this._assetLoader.loadImage(path);
    }

    /** 加载图集 */
    async loadSpriteAtlas(path: string): Promise<any> {
        return this._assetLoader.loadSpriteAtlas(path);
    }

    /** 加载音频 */
    async loadAudioClip(path: string): Promise<any>{
        return this._assetLoader.loadAudioClip(path);
    }

    /** 加载配置 */
    async loadConfig(path: string): Promise<any>{
        return this._assetLoader.loadConfig(path);
    }

    /** 加载动画Clip */
    async loadAnimClip(path: string): Promise<any> {
        return this._assetLoader.loadAnimClip(path);
    }

    async loadAssetsAsync(path: string){
        this._assetLoader.loadAssetsAsync(path);
    }

    releaseRes(resPath: string) {
        this._assetLoader.releaseRes(resPath);
    }
}
